package pe.edu.upc.dsd.whereeat.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.upc.dsd.whereeat.base.dao.BaseDAO;
import pe.edu.upc.dsd.whereeat.base.service.impl.BaseServiceImpl;
import pe.edu.upc.dsd.whereeat.dao.PlatoDAO;
import pe.edu.upc.dsd.whereeat.domain.Plato;
import pe.edu.upc.dsd.whereeat.service.PlatoService;

@Service
public class PlatoServiceImpl extends BaseServiceImpl<Plato, Integer> implements
		PlatoService {

	@Autowired
	private PlatoDAO platoDAO;

	@Override
	protected BaseDAO<Plato, Integer> getBaseDAO() {
		// TODO Auto-generated method stub
		return platoDAO;
	}

	@Override
	public List<Plato> obtenerPlatosPorRestaurantId(int restaurantId)
			throws Exception {
		// TODO Auto-generated method stub
		return platoDAO.obtenerPlatosPorRestaurantId(restaurantId);
	}

	@Override
	@Transactional
	public void delete(Plato plato) throws Exception {
		Plato x = getBaseDAO().findById(plato.getCodigo());
		getBaseDAO().delete(x);
	}
}
